package cn.yeziji.forum.common;

import cn.yeziji.forum.utils.AesUtils;

import java.security.GeneralSecurityException;

/**
 * 密码加密
 *
 * @author gzkemays
 * @since 2021/12/21 16:11
 */
public class PasswordSecurity {
  protected static final String SECURITY = "u9Aj913MtP7J2Rq@Yzj_forum-gzkemays";

  public static String generatedPassword(String pwd) {
    return AesUtils.encrypt(pwd, SECURITY);
  }

  public static String parsePassword(String pwd) {
    return AesUtils.decrypt(pwd, SECURITY);
  }

  private static String getIndex(String str) {
    byte[] bytes = str.getBytes();
    StringBuilder result = new StringBuilder();
    for (byte b : bytes) {
      result.append(b);
    }
    return result.toString();
  }
}
